(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.popup.custAcctViewController', custAcctViewController);
	custAcctViewController.$inject = [ '$scope', '$q', '$uibModalInstance', 'Constants', 'dialogsModule', 'gridService', 'modalService', 'layoutConfig' , 'authService', 'ajaxServiceFactory', 'validatorConfig', 'arithService', 'custAcctService'];
	function custAcctViewController($scope, $q, $uibModalInstance, Constants, dialogsModule, gridService, modalService, layoutConfig, authService, ajaxServiceFactory, validatorConfig, arithService, custAcctService) {
		var ctrl = this, log = $scope.loggerFactory.getLogger("custAcctViewController"), ajaxService = ajaxServiceFactory.buildAjaxService({
			getCustAcctView : {
				url : 'do/cda/custAcct/getCustAcct',
				method : 'post'
			},
		});
		ctrl.dialogsModule = dialogsModule;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.custAcctId = ctrl.dialogsModule.params.custAcctId || '';
		ctrl.formName = "custAcctForm";
		custAcctService.initFunction(ctrl);
		
		ctrl.init = function() {
			var params = {};
			params.custAcctId = ctrl.custAcctId;
			custAcctService.initOptions().then(function(response) {
				ctrl.custAcctTypeOptions = response.custAcctTypeOptions;
				ctrl.ccyOptions = response.ccyOptions;
				ctrl.paycodeCatOptions = response.paycodeCatOptions;
				ctrl.allPartyTypeOptions = response.allPartyTypeOptions;
				ctrl.yesNoOptions = response.yesNoOptions;
				ctrl.yesNoOptionsb = response.yesNoOptionsb;
				ctrl.swiftCaseList = response.swiftCaseList;
				ctrl.accountPatterns = response.accountPatterns;
				ctrl.accountPatternsTwo = response.accountPatternsTwo;
				
				ctrl.partyCountrys = response.countryOptionAll;
				ctrl.partyStates = response.stateOptionAll;
				ctrl.partyCitys = response.cityOptionAll;
				ctrl.stateList = response.stateList;
				ctrl.cityList = response.cityList;
				ctrl.partyStatesCatch = response.stateOptionAll;
				ctrl.partyCitysCatch = response.cityOptionAll;
				
				ajaxService.getCustAcctView(params).then(function(response) {
					ctrl.custAcct = response.data || custAcctInfo;
					ctrl.initPyPartyTabs();
				});
			});
		};
		
		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['close'] || dialogsModule.btnCallback['close']() !== false) {
				$uibModalInstance.dismiss();
			}
		};
		
	}
})(angular);
